package com.xiaoxiong.gobang;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;

import com.xiaoxiong.gobang.ui.GameView;
import com.xiaoxiong.gobang.ui.Test;

public class MainActivity extends Activity {

    private RelativeLayout r;
    private Test t;
    private GameView gameView;
    private Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        r = (RelativeLayout) findViewById(R.id.re);
        gameView = (GameView) findViewById(R.id.game);
        button = (Button) findViewById(R.id.but);
        t = new Test();
        t.Init();
        on();
    }

    private void on() {
        r.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                switch (event.getAction()) {
                    case MotionEvent.ACTION_UP:
                        gameView.setXY(event.getX(), event.getY() - button.getHeight());
//                        Log.e("下棋", String.valueOf((event.getX() + event.getY() * 10 + 11)));
                        t.setPos(15);
                        break;
                }

                return true;
            }
        });
    }
}
